<?php
declare (strict_types = 1);

namespace app\mini\controller;

use app\admin\model\Setting;
use app\admin\model\Slideshow;
use think\response\Json;
use app\mini\model\SysModelMiniCustomer;
use app\crm\model\Customer as CustomerModel;
use app\mini\model\PersonCustomer;
use app\crm\model\Setting as SettingModel;
use app\mini\model\PersonCase as PersonCaseModel;
use app\crm\model\ReturnVist;
use app\admin\model\File as FileModel;
use app\mini\model\AddModel;

use think\facade\Db;
/**
 * Class Index
 * @package app\mini\controller
 * @author Mr.Liu Wuchen
 * @create 2021-07-02 10:42
 */
class IndexCustomer extends Access
{
    /**
     * 客户小程序新增服务评价接口
     * @return Json
     * @author yp
     */
    public function addEvaluation():Json
    {
        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        $data = $model->addEvaluation($request);

        return resultArray(['error' => '评价成功', 'data' => $data]);
    }

    /**
     * 获取当前月份日期
     * @return Json
     * @author YP
     */
    public function getMonthDays():Json
    {
        $time = time();
        $year = date('Y',$time);
        $month = date('m',$time);
        $t = date('t',$time)+7;

        $timeStr = strtotime($year.'-'.$month.'-'.'01');

        $date = [];

        for($i=0;$i<$t;$i++){

            $timeS = $timeStr+86400*$i;

            $days = date('m-d',$timeS);

            // $days = '';

            // $days = $month.'-'.$i;

            array_push($date,$days);

        }

        // echo "<pre>";
        // print_r($date);
        // echo "</pre>";
        // exit;

        return resultArray(['error' => '获取成功', 'data' => $date]);
    }

    /**
     * 获取员工当月排班列表
     * @return Json
     * @author YP
     */
    public function scheduleList(): Json
    {

        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        $data = $model->getScheduleList($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
         
    }

    /**
     * 设置员工排班
     * @return Json
     * @author YP
     */
    public function setSchedule()
    {
        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        $data = $model->setSchedule($request);

        if (!$data) {

            return resultArray(['error' => $model->error]);

        }

        return resultArray(['data' => $data,'msg' =>"编辑完成"]);
    }


    /**
     * 客户小程序获取门店信息
     * @return Json
     * @author YP
     */
    public function getShopInfo(): Json
    {
        $request = $this->request->param();

        // echo "<pre>";
        // print_r($request);
        // echo "</pre>";
        // exit;

        $model = new SysModelMiniCustomer();

        $data = $model->getShopInfo($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    /**
     * 获取可预约日期
     * @return Json
     * @author YP
     */
    public function bookDate(): Json
    {

        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        $data = $model->bookDate($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
        
    }

    /**
     * 获取规定日期可预约的时间段
     * @return Json
     * @author YP
     */
    public function bookTime(): Json
    {
        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        $data = $model->bookTime($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    /**
     * 获取规定日期可预约的时间段
     * @return Json
     * @author YP
     */
    public function bookTime2(): Json
    {
        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        $data = $model->bookTime2($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    /**
     * 获取可预约护理师列表
     * @return Json
     * @author YP
     * 参数：预约日期，预约时间，预约门店
     */
    public function getYYStaff(): Json
    {
        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        $data = $model->getYYStaff($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }


    /**
     * 提交预约信息
     * @return Json
     * @author YP
     * 参数：预约日期，预约时间，预约门店
     */
    public function submitYYInfo(): Json
    {

        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        // $request['msg'] = '预约参数';

        $data = $model->addYYData($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);

    }

    /**
     * 提交预约信息
     * @return Json
     * @author YP
     * 参数：预约日期，预约时间，预约门店
     */
    public function submitYYInfo2(): Json
    {

        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        // $request['msg'] = '预约参数';

        $data = $model->addYYData2($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);

    }

    /**
     * 客户小程序获取预约列表
     * @return Json
     * @author YP
     * 参数：
     */
    public function getBookList(): Json
    {

        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        $data = $model->getBookList($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);

    }

    /**
     *  客户小程序满意度调查客户结果提接口
     *  @return Json
     */
    public function addQuestionCustomer(): Json
    {
        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        $data = $model->addQuestionCustomer($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    /**
     *  取消预约信息
     *  @return Json
     */
    public function cancelBook(): Json
    {

        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        $data = $model->cancelBook($request);

        return resultArray(['error' => '操作成功', 'data' => $data]);
        

    }

    /**
     * getSetting category_id = 14
     * @return Json
     */
    public function getSetting14(): Json
    {
        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        $data = $model->getSetting14($request);

        return resultArray(['error' => '获取成功', 'data' => $data]);
    }

    /**
     * 新增意见反馈
     */
    public function addFeedback(): Json
    {
        $request = $this->request->param();

        $model = new AddModel();

        $data = $model->addFeedback($request);

        return resultArray(['error' => '新增成功', 'data' => $data]);
    }

    /**
     * 一次性设置一周排班
     */
    public function setScheduleWeek(): Json
    {
        $request = $this->request->param();

        $model = new SysModelMiniCustomer();

        $data = $model->setScheduleWeek($request);

        if (!$data) {

            return resultArray(['error' => $model->error]);

        }

        return resultArray(['data' => $data,'msg' =>"编辑完成"]);
    }

}

